var express = require('express');
var router = express.Router();
var mongo = require('mongodb');

const examinationControl = require('../bin/control/examinationControl')
const userControl = require('../bin/control/userControl')
const paper = require('../bin/control/paperControl')


router.get("/examinationAdd", (req, res) => { //文章增加页
  res.render('examinationAdd');
})

router.get('/examinationList', function (req, res, next) { // 所有的问题
  var page = parseInt(req.query.page);
  if (!page) {
    page = 1;
  }
  paper.getList(data => {
    console.log(data)
    res.render('examinationList', { data: JSON.stringify(data), data_h: data,number:2,page:1});
  })

});

router.get('/examinationEditor', function (req, res, next) { // 查看单一用户
  let _id = req.query.id;
  console.log(_id)
  examinationControl.findOneExamination(_id, (result) => {
    res.render('examinationEditor', { userData: result, _id: _id });
  })
});



module.exports = router;
